-- HOW TO USE
-- replace all 'Foster_ScrumFactory' strings for your new database name
-- replace all 'Factory' strings for your old database name


DELETE [Foster_ScrumFactory].[factory].[MemberAvatar]
DELETE [Foster_ScrumFactory].[factory].[MemberProfile]
DELETE [Foster_ScrumFactory].[factory].ItemSize
DELETE [Foster_ScrumFactory].[factory].Risk
DELETE [Foster_ScrumFactory].[factory].PlannedHours
DELETE [Foster_ScrumFactory].[factory].ProjectMembership
DELETE [Foster_ScrumFactory].[factory].[Role]
DELETE [Foster_ScrumFactory].[factory].RoleHourCost
DELETE [Foster_ScrumFactory].[factory].Sprint
DELETE [Foster_ScrumFactory].[factory].BacklogItem
DELETE [Foster_ScrumFactory].[factory].BacklogItemGroup
DELETE [Foster_ScrumFactory].[factory].ProposalClause
DELETE [Foster_ScrumFactory].[factory].ProposalDocument
DELETE [Foster_ScrumFactory].[factory].ProposalFixedCost
DELETE [Foster_ScrumFactory].[factory].ProposalItem
DELETE [Foster_ScrumFactory].[factory].Proposal
DELETE [Foster_ScrumFactory].[factory].Project
DELETE [Foster_ScrumFactory].[factory].TaskDetail
DELETE [Foster_ScrumFactory].[factory].Task



INSERT [Foster_ScrumFactory].[factory].[ItemSize] ([ItemSizeUId], [Name], [Description], [Size], [OccurrenceConstraint], [IsActive]) VALUES (N'8b7800af-e5a0-413a-891f-65208890de5d', N'Delivery', N'Delivery sprint', 8, 2, 1)
INSERT [Foster_ScrumFactory].[factory].[ItemSize] ([ItemSizeUId], [Name], [Description], [Size], [OccurrenceConstraint], [IsActive]) VALUES (N'd3e9bd76-1429-4253-ac57-30dddfcf1a9d', N'Planning & Review', N'Review the previuos sprint and plan the current one', 8, 0, 1)



-- MEMBERS ---------------------------------------------------
PRINT 'Importing members'
INSERT INTO [Foster_ScrumFactory].[factory].[MemberProfile]
           ([MemberUId]
           ,[EmailAccount]
           ,[FullName]
           ,[IsFactoryOwner]
           ,[CanSeeProposalValues]
           ,[CompanyName]
           ,[Skills]
           ,[ContactData]
           ,[AuthorizationProvider],
           CreateBy)
SELECT
	MemberId,
	EmailAccount,
	NickName,
	FactoryOwnerRole,
	CommercialGuyRole,
	Company,
	'',
	ContactData,
	'Windows Authentication',
	MemberId
FROM
	Factory.factory.Member
WHERE
	ClientContactRole = 0
	AND AccessKey is null

INSERT INTO [Foster_ScrumFactory].[factory].[MemberAvatar]
           ([MemberUId]
           ,[AvatarImage])
SELECT
	MemberId,
	MemberImage
FROM	           	
	Factory.factory.MemberAvatar
	

PRINT 'Importing contacts'
INSERT INTO [Foster_ScrumFactory].[factory].[MemberProfile]
           ([MemberUId]
           ,[EmailAccount]
           ,[FullName]
           ,[IsFactoryOwner]
           ,[CanSeeProposalValues]
           ,[CompanyName]
           ,[Skills]
           ,[ContactData]
           ,[AuthorizationProvider]
           ,CreateBy)
SELECT
	MemberId,
	EmailAccount,
	NickName,
	0,
	0,
	Company,
	'',
	ContactData,
	'Factory Contact'
	,'marcos.martins@foster.srv.br'
FROM
	Factory.factory.Member
WHERE
ClientContactRole = 1	           

-- PROJECTS ---------------------------------------------------

DECLARE @ProjectNumber int;
DECLARE @ProjectUId char(38);
DECLARE @Mode smallint;

DECLARE prjs CURSOR FOR 
	SELECT
		ProjectNumber, ProjectUId, HourBankMode
	FROM 
		Factory.factory.Project
	order by 
		ProjectNumber


OPEN prjs;

FETCH NEXT FROM prjs INTO @ProjectNumber, @ProjectUId, @Mode;

WHILE @@FETCH_STATUS = 0
BEGIN
	

    PRINT 'Importing project ' + CAST(@ProjectNumber as varchar);

	SET IDENTITY_INSERT [Foster_ScrumFactory].factory.Project ON;
    
    if @Mode = 0
		INSERT INTO [Foster_ScrumFactory].factory.Project
				([ProjectUId]
				,[ProjectNumber]
			   ,[ProjectName]
			   ,[ClientName]
			   ,[Status]
			   ,[CreateDate]
			   ,[CreateBy]
			   ,[Description]
			   ,[Platform]
			   ,[StartDate]
			   ,[EndDate]
			   ,[CodeRepositoryPath]
			   ,[DocRepositoryPath]
			   ,[IsSuspended]
			   ,ProjectType
			   ,AnyoneCanJoin
			   ,ProjectParentUId)
		SELECT
			ProjectUId,
			ProjectNumber,
			ProjectName,
			ClientName,
			CASE [Status]
				WHEN 0 THEN 0
				WHEN 1 THEN 0
				WHEN 2 THEN 0
				WHEN 3 THEN 1
				WHEN 4 THEN 2
				WHEN 5 THEN 3
				WHEN 6 THEN 3
				WHEN 7 THEN 5
				WHEN 8 THEN 4
				WHEN 9 THEN 4
				WHEN 10 THEN 4
			END,		
			CreateDate,
			ProjectOwner,
			[Description],
			Plataform,
			StartDate,
			EndDate,
			'',
			ProjectDocBase,
			IsSuspended,
			0,
			1,
			PaymentProjectUId		
		FROM Factory.factory.Project
		WHERE
		ProjectNumber = @ProjectNumber
    ELSE
		INSERT INTO [Foster_ScrumFactory].factory.Project
				([ProjectUId]
				,[ProjectNumber]
			   ,[ProjectName]
			   ,[ClientName]
			   ,[Status]
			   ,[CreateDate]
			   ,[CreateBy]
			   ,[Description]
			   ,[Platform]
			   ,[StartDate]
			   ,[EndDate]
			   ,[CodeRepositoryPath]
			   ,[DocRepositoryPath]
			   ,[IsSuspended]
			   ,ProjectType
			   ,AnyoneCanJoin
			   ,ProjectParentUId)
		SELECT
			ProjectUId,
			ProjectNumber,
			ProjectName,
			ClientName,
			CASE [Status]
				WHEN 0 THEN 0
				WHEN 1 THEN 0
				WHEN 2 THEN 0
				WHEN 3 THEN 1
				WHEN 4 THEN 2
				WHEN 5 THEN 5
				WHEN 6 THEN 5
				WHEN 7 THEN 5
				WHEN 8 THEN 4
				WHEN 9 THEN 4
				WHEN 10 THEN 4
			END,		
			CreateDate,
			ProjectOwner,
			[Description],
			Plataform,
			StartDate,
			EndDate,
			'',
			ProjectDocBase,
			IsSuspended,
			20,
			1,
			PaymentProjectUId
		FROM Factory.factory.Project
		WHERE
		ProjectNumber = @ProjectNumber

	SET IDENTITY_INSERT [Foster_ScrumFactory].factory.Project OFF;
	    
    -- SPRINTS ---------------------------------------------------
    PRINT '---> Importing sprints';
    INSERT INTO [Foster_ScrumFactory].[factory].[Sprint]
           ([SprintUId]
           ,[SprintNumber]
           ,[ProjectUId]
           ,[StartDate]
           ,[EndDate])
    SELECT
		SprintUId,
		SprintNumber,
		ProjectUId,
		ExpirationDate,
		ExpirationDate
	FROM
		Factory.factory.Sprint
	where
		ProjectUId = @ProjectUId

	-- ROLES AND COSTS ---------------------------------------------------
	PRINT '---> Importing roles';
	-- PERMISSIONS SETS vs TYPE
	-- 1 --> SCRUM_MASTER = 0
    -- 3 --> TEAM = 1,
    -- 6 --> PRODUCT_OWNER = 2
    -- 5 --> COMMERCIAL_GUY = 3
    INSERT INTO [Foster_ScrumFactory].[factory].[Role]
           ([RoleUId]
           ,[RoleShortName]
           ,[ProjectUId]
           ,[RoleName]
           ,[RoleDescription]
           ,[PermissionSet]
           ,[IsPlanned])
    SELECT
		NEWID(),
		UnitName,
		ProjectUId,
		UnitDescription,
		'',
		CASE [Type]
			WHEN 1 THEN 0 -- SCRUM MASTER
			WHEN 3 THEN 1 -- TEAM
			WHEN 6 THEN 2 -- PRODUCT OWNER
			WHEN 5 THEN 3 -- COMMERCIAL GUY
			ELSE 1
		END,
		CASE [Type]			
			WHEN 6 THEN 0 -- PRODUCT OWNER
			WHEN 5 THEN 0 -- COMMERCIAL GUY
			ELSE 1
		END
	FROM
		Factory.factory.BacklogItemUnit
	WHERE
		ProjectUId = @ProjectUId
		
	-- IMPORT ROLES FROM TASKS
	PRINT '---> Importing rols from tasks';			
	 INSERT INTO [Foster_ScrumFactory].[factory].[Role]
           ([RoleUId]
           ,[RoleShortName]
           ,[ProjectUId]
           ,[RoleName]
           ,[RoleDescription]
           ,[PermissionSet]
           ,[IsPlanned])
    SELECT
		NEWID(),
		UnitName,
		@ProjectUId,
		UnitName,
		UnitName,
		1,
		1
	FROM
		[Factory].factory.Task
	WHERE ProjectUId =	@ProjectUId
	AND UnitName not in (SELECT RoleShortName FROM [Foster_ScrumFactory].factory.[Role] WHERE ProjectUId = @ProjectUId)
	GROUP BY TaskAssignee, UnitName	
	
	PRINT '---> Importing roles costs';
	INSERT INTO [Foster_ScrumFactory].[factory].[RoleHourCost]
           ([RoleUId]
           ,[ProjectUId]
           ,[Cost]
           ,[Price])
	SELECT
		(SELECT RoleUId FROM [Foster_ScrumFactory].factory.[Role] WHERE ProjectUId = @ProjectUId AND RoleShortName = Factory.factory.BacklogItemUnit.UnitName),
		ProjectUId,
		UnitCostValue,
		UnitSaleValue
	FROM
		Factory.factory.BacklogItemUnit    
	WHERE
		ProjectUId = @ProjectUId	

	-- MEMBERSHIPS ---------------------------------------------------	    
	PRINT '---> Importing memberships';			
	INSERT INTO [Foster_ScrumFactory].[factory].[ProjectMembership]
           ([ProjectUId]
           ,[MemberUId]
           ,[RoleUId]
           ,[DayAllocation]
           ,[IsActive]
           ,[InactiveSince])
    SELECT
		ProjectUId,
		ContactId,
		(SELECT RoleUId FROM [Foster_ScrumFactory].factory.[Role] WHERE ProjectUId = @ProjectUId AND RoleShortName =  Factory.factory.ProjectRole.UnitName),
		0,
		1,
		null
	FROM
		Factory.factory.ProjectRole
	WHERE
		ProjectUId = @ProjectUId	
		
	-- SCRUM MASTER
	INSERT INTO [Foster_ScrumFactory].[factory].[ProjectMembership]
           ([ProjectUId]
           ,[MemberUId]
           ,[RoleUId]
           ,[DayAllocation]
           ,[IsActive]
           ,[InactiveSince])
    VALUES(
		@ProjectUId,
		(SELECT ProjectOwner FROM Factory.factory.Project WHERE ProjectUId = @ProjectUId),
		(SELECT TOP 1 RoleUId FROM [Foster_ScrumFactory].factory.[Role] WHERE ProjectUId = @ProjectUId AND PermissionSet = 0),
		0,
		1,
		null)
	
	-- IMPORT MEMBERS THAT HAVE TASKS BUT IS NOT AT PROJECT
	PRINT '---> Importing memberships from tasks';			
	INSERT INTO [Foster_ScrumFactory].[factory].[ProjectMembership]
           ([ProjectUId]
           ,[MemberUId]
           ,[RoleUId]
           ,[DayAllocation]
           ,[IsActive]
           ,[InactiveSince])
    SELECT
		@ProjectUId,
		TaskAssignee,
		(SELECT RoleUId FROM [Foster_ScrumFactory].factory.[Role] WHERE ProjectUId = @ProjectUId AND RoleShortName = UnitName),
		0,
		1,
		null
	FROM
		[Factory].factory.Task
	WHERE ProjectUId =	@ProjectUId
	AND TaskAssignee not in (SELECT memberUId FROM [Foster_ScrumFactory].factory.ProjectMembership WHERE ProjectUId = @ProjectUId)
	GROUP BY TaskAssignee, UnitName	
	
	-- RISKS ---------------------------------------------------
	PRINT '---> Importing risks';
	INSERT INTO [Foster_ScrumFactory].[factory].[Risk]
           ([RiskUId]
           ,[ProjectUId]
           ,[RiskDescription]
           ,[CreateDate]
           ,[Impact]
           ,[Probability]
           ,[IsPrivate]
           ,[RiskAction]
           ,[UpdatedAt])
    SELECT
		RiskUId,
		ProjectUId,
		RiskName,
		CreateDate,
		Impact,
		Probability,
		0,
		Actions,
		CreateDate
	FROM
		Factory.factory.Risk
	WHERE
		ProjectUId = @ProjectUId
		
	-- ITEMS GROUPS ---------------------------------------------------
	PRINT '---> Importing items groups';	
	INSERT INTO [Foster_ScrumFactory].[factory].[BacklogItemGroup]
           ([GroupUId]
           ,[ProjectUId]
           ,[GroupName]
           ,[GroupColor]
           ,[DefaultGroup])
    SELECT
		NEWID(),
		@ProjectUId,
		GroupName,
		'Transparent',
		0		
	FROM
		Factory.factory.BacklogItem
	WHERE
		ProjectUId = @ProjectUId       	
	GROUP BY
		GroupName
	
	-- ITEMS ---------------------------------------------------
	PRINT '---> Importing items';	
	
	DECLARE @maxPriority int;
	SELECT @maxPriority = MAX(BusinessValue) FROM Factory.factory.BacklogItem WHERE ProjectUId = @ProjectUId
	
	INSERT INTO [Foster_ScrumFactory].[factory].[BacklogItem]
           ([BacklogItemUId]
           ,[BacklogItemNumber]
           ,[ProjectUId]
           ,[Name]
           ,[Description]
           ,[Status]
           ,[CreateDate]
           ,[DeliveryDate]
           ,[StartedAt]
           ,[FinishedAt]
           ,[BusinessPriority]
           ,[Size]
           ,[ItemSizeUId]
           ,[OccurrenceConstraint]
           ,[GroupUId]
           ,[IssueType]
           ,[CancelReason]
           ,[SizeFactor])
    SELECT
		BacklogItemUId,
		BacklogItemNumber,
		ProjectUId,
		Title,
		[Description],
		[Status],
		CreateDate,
		null,
		StartDate,
		FinishDate,
		ISNULL(@maxPriority + 1 - BusinessValue, 1),
		null,
		null,
		1,
		(SELECT GroupUId FROM [Foster_ScrumFactory].factory.BacklogItemGroup WHERE ProjectUId = @ProjectUId AND GroupName = Factory.factory.BacklogItem.GroupName),
		IsBugCorrection,
		CancelReason,
		1
	FROM
		Factory.factory.BacklogItem
	WHERE
		ProjectUId = @ProjectUId;
		
	-- PLANNED HOURS ---------------------------------------------------
	PRINT '---> Importing planned hours';	
	INSERT INTO [Foster_ScrumFactory].[factory].[PlannedHours]
       ([BacklogItemUId]
       ,[RoleUId]
       ,[PlanningNumber]
       ,[SprintNumber]
       ,[Hours])
    SELECT
		BacklogItemUId,
		(SELECT RoleUId FROM [Foster_ScrumFactory].factory.[Role] WHERE ProjectUId = @ProjectUId AND RoleShortName =  Factory.factory.BacklogItemHours.UnitName),
		BaseLine,
		(SELECT SprintNumber FROM Factory.factory.Sprint WHERE ProjectUId = @ProjectUId AND SprintUId = Factory.factory.BacklogItemHours.SprintUId),
		Quantity
	FROM
		Factory.factory.BacklogItemHours
	WHERE
		ProjectUId = @ProjectUId     
	
	-- PROPOSALS ---------------------------------------------------
	PRINT '---> Importing proposals';	
	INSERT INTO [Foster_ScrumFactory].[factory].[Proposal]
           ([ProposalUId]
           ,[ProjectUId]
           ,[ProposalName]
           ,[ProposalStatus]
           ,[CreateDate]
           ,[EstimatedStartDate]
           ,[EstimatedEndDate]
           ,[CurrencySymbol]
           ,[TotalValue]
           ,[Discount]
           ,[UseCalcPrice]
           ,[TemplateName]
           ,[Description]
           ,[ApprovalDate]
           ,[ApprovedBy]
           ,[RejectReason])
     SELECT
		ProposalUId,
		ProjectUId,
		ProposalName,
		CASE [Status]
			WHEN 0 THEN 0
			WHEN 1 THEN 0
			WHEN 2 THEN 0
			WHEN 3 THEN 1
			WHEN 4 THEN 2
		END,
		CreateDate,
		StartDate,
		EndDate,
		MoneyShortName,
		SalePrice,
		Discount,
		UseDiscount,
		TemplateName,
		Details,
		ApprovalDate,
		'unknow',
		RejectReason		
	 FROM
		Factory.factory.Proposal
	WHERE
		ProjectUId = @ProjectUId
		
	-- PROPOSALS DOCUMENTS ---------------------------------------------------
	PRINT '---> Importing proposals documents';	
	INSERT INTO [Foster_ScrumFactory].[factory].[ProposalDocument]
           ([ProposalUId]
           ,[ProposalXAML])
    SELECT
		ProposalUId,
		ProposalXAML
	FROM
		Factory.factory.ProposalApproved
	WHERE
		ProposalUId IN (SELECT ProposalUId FROM Factory.factory.Proposal WHERE ProjectUId = @ProjectUId)
		
	-- PROPOSALS CLAUSES ---------------------------------------------------
	PRINT '---> Importing proposals clauses';	
	INSERT INTO [Foster_ScrumFactory].[factory].[ProposalClause]
           ([ProposalUId]
           ,[ClauseOrder]
           ,[ClauseName]
           ,[ClauseText])
     SELECT
		ProposalUId,
		[Order],
		ObservationName,
		ObservationText
	FROM
		Factory.factory.ProposalObservation
	WHERE
		ProposalUId IN (SELECT ProposalUId FROM Factory.factory.Proposal WHERE ProjectUId = @ProjectUId)
	
	-- PROPOSALS COSTS ---------------------------------------------------
	PRINT '---> Importing proposals fixed costs';	
	INSERT INTO [Foster_ScrumFactory].[factory].[ProposalFixedCost]
           ([ProposalFixedCostUId]
           ,[ProposalUId]
           ,[CostDescription]
           ,[Cost]
           ,[RepassToClient])
     SELECT
		FixedPriceItemUId,
		ProposalUId,
		ItemName,
		ItemValue,
		Payable
	FROM
		Factory.factory.ProposalFixedCostItem
	WHERE
		ProposalUId IN (SELECT ProposalUId FROM Factory.factory.Proposal WHERE ProjectUId = @ProjectUId)
		
	-- PROPOSALS ITEMS ---------------------------------------------------
	PRINT '---> Importing proposals items';	
	INSERT INTO [Foster_ScrumFactory].[factory].[ProposalItem]
           ([ProposalUId]
           ,[BacklogItemUId])
     SELECT
		ProposalUId,
		BacklogItemUId		
	FROM
		Factory.factory.ProposalItem
	WHERE
		ProposalUId IN (SELECT ProposalUId FROM Factory.factory.Proposal WHERE ProjectUId = @ProjectUId)
		
	-- TASKS ---------------------------------------------------
	PRINT '---> Importing tasks';		
	
	
	SET IDENTITY_INSERT [Foster_ScrumFactory].[factory].[Task] ON;
	
	INSERT INTO [Foster_ScrumFactory].[factory].[Task]
           ([TaskUId]
           , TaskNumber
           ,[TaskName]
           ,[TaskOwnerUId]
           ,[ProjectUId]
           ,[BacklogItemUId]
           ,[Priority]
           ,[TaskType]
           ,[CreatedAt]
           ,[Status]
           ,[PlannedHours]
           ,[EffectiveHours]
           ,[TaskAssigneeUId]
           ,[RoleUId]
           ,[EndDate]
           ,[StartDate]
           ,[IsAccounting])
    SELECT
		TaskUId,
		TaskId,
		TaskName,
		TaskOwner,
		ProjectUId,
		BacklogItemUId,
		Priority,
		CASE TaskType
			WHEN 0 THEN 1
			WHEN 1 THEN 4
			WHEN 2 THEN 5
			WHEN 3 THEN 2
			WHEN 4 THEN 3
		END,
		CreateDate,
		CASE [Status]
			WHEN 0 THEN 0
			WHEN 1 THEN 0
			WHEN 2 THEN 1
			WHEN 3 THEN 2
			WHEN 4 THEN 2
			WHEN 5 THEN 3
		END,
		PlannedEffort,
		ActualEffort,
		TaskAssignee,
		(SELECT RoleUID FROM [Foster_ScrumFactory].factory.Role WHERE ProjectUId = @ProjectUId AND RoleShortName = Factory.factory.Task.UnitName),
		Finish,
		Start,
		Payable
	FROM
		Factory.factory.Task
	WHERE
		ProjectUId = @ProjectUId
		
	SET IDENTITY_INSERT [Foster_ScrumFactory].[factory].[Task] OFF;

	-- TASKS DETAILS ---------------------------------------------------
	PRINT '---> Importing tasks details';	
	INSERT INTO [Foster_ScrumFactory].[factory].[TaskDetail]
           ([TaskUId]
           ,[Detail])
	SELECT
		TaskUId,
		TaskDescription           
    FROM
		Factory.factory.Task
	WHERE
		ProjectUId = @ProjectUId
	AND
		TaskDescription IS NOT NULL
		
    FETCH NEXT FROM prjs INTO @ProjectNumber, @ProjectUId, @Mode;
END

-- clean member garbage
DELETE FROM [Foster_ScrumFactory].factory.ProjectMembership
WHERE MemberUId NOT IN (SELECT MemberUId FROM [Foster_ScrumFactory].factory.Memberprofile)

-- set sprint start dates
UPDATE
[Foster_ScrumFactory].factory.Sprint 
SET StartDate =
	(SELECT EndDate FROM [Foster_ScrumFactory].factory.Sprint s WHERE s.ProjectUId = [Foster_ScrumFactory].factory.Sprint.ProjectUId AND s.SprintNumber = [Foster_ScrumFactory].factory.Sprint.SprintNumber - 1)
WHERE SprintNumber > 1

UPDATE
[Foster_ScrumFactory].factory.Sprint 
SET StartDate =
	(SELECT EstimatedStartDate FROM [Factory].factory.Project p WHERE p.ProjectUId = [Foster_ScrumFactory].factory.Sprint.ProjectUId)
WHERE SprintNumber = 1

-- fixing windows memeberUId

-- disable all constraints
USE [Foster_ScrumFactory]
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"

update
 [Foster_ScrumFactory].factory.ProjectMembership
 set MemberUId = REPLACE(MemberUId, 'FOSTER\', '') + '@foster.srv.br'
 where MemberUId like 'FOSTER\%'
 

update
 [Foster_ScrumFactory].factory.Task
 set TaskAssigneeUId = REPLACE(TaskAssigneeUId, 'FOSTER\', '') + '@foster.srv.br'
 WHERE TaskAssigneeUId like 'FOSTER\%'

 update
 [Foster_ScrumFactory].factory.Task
 set TaskOwnerUId = REPLACE(TaskOwnerUId, 'FOSTER\', '') + '@foster.srv.br'
 WHERE TaskOwnerUId like 'FOSTER\%'

 update [Foster_ScrumFactory].factory.MemberAvatar
 set MemberUId = REPLACE(MemberUId, 'FOSTER\', '') + '@foster.srv.br'
 WHERE MemberUId like 'FOSTER\%'
 
 update [Foster_ScrumFactory].factory.MemberProfile
 set MemberUId = REPLACE(MemberUId, 'FOSTER\', '') + '@foster.srv.br'
 WHERE MemberUId like 'FOSTER\%'

-- enable all constraints
exec sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"



CLOSE prjs;
DEALLOCATE prjs;

